package com.validate.data;

import com.validate.annotation.MyValidate;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;
import java.time.LocalDateTime;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class User {
    @NotBlank(message = "id不能为空！")
    private String id;

    @AssertTrue(message = "isFriend必须为true！")
    private boolean isFriend;

    @Min(value = 0, message = "age必须大于0！")
    @Max(value = 150, message = "age必须小于150！")
//    @Size(min = 0, max = 150, message = "age必须大于0且小于150！")
    private Integer age;

    @Past(message = "birth必须是一个过去的时间！")
//    @Future
    private LocalDateTime birth;

    @Email(message = "email格式错误！")
    private String email;

    @Length(min = 0, max = 4, message = "username长度必须小于4！")
    private String username;

    @MyValidate(message = "password不能包含空格！")
    private String password;

    @Pattern(regexp = "^1[34578]\\d{9}$", message = "phone格式错误！")
    private String phone;

}
